<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/OrderStatus/orderStatus"
          method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="orderStatus"/>
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel"/>
            <label>订单号：</label>
            <input type="text" name="docId" value="${docId}" size="16" placeholder="订单号"/>&nbsp;
            <label>存货编码：</label>
            <input type="text" name="partName" value="${partName}" size="16" placeholder="存货编码"/>&nbsp;
        %{--<g:select name="partName" from="${orderStatusAnalysisPartName}" data-toggle="selectpicker" data-live-search="true" optionKey="part_name" optionValue="part_name" value="${partName}" noSelection="['':'ALL']" />&nbsp;--}%
            <label>产品名称：</label>
            <input type="text" name="partDesc" value="${partDesc}" size="16" placeholder="产品名称"/>&nbsp;
        %{--<g:select name="partDesc" from="${orderStatusAnalysisPartDesc}" data-toggle="selectpicker" data-live-search="true" optionKey="part_desc" optionValue="part_desc" value="${partDesc}" noSelection="['':'ALL']" />&nbsp;--}%
            <label>图号：</label>
            <input type="text" name="group3" value="${group3}" size="16" placeholder="图号"/>&nbsp;
        %{--<g:select name="group3" from="${orderStatusAnalysisGroupList}" data-toggle="selectpicker" data-live-search="true" optionKey="group3" optionValue="group3" value="${group3}" noSelection="['':'ALL']" />&nbsp;--}%
            <label>订单状态：</label>
            <g:select name="startedState" from="${orderStatusAnalysisStartedList}" data-toggle="selectpicker"
                      data-live-search="true" optionKey="doc_status" optionValue="doc_state" value="${startedState}"
                      data-width="130" noSelection="['': '-- All --']"/>
            <br/><br/>
            <label>计划完成日期：</label>
            <input type="text" name="startTime" value="${startTime}" size="12" data-pattern="yyyy/MM/dd"
                   data-toggle="datepicker"
                   placeholder="FROM">
            <input type="text" name="endTime" value="${endTime}" size="12" data-pattern="yyyy/MM/dd"
                   data-toggle="datepicker"
                   placeholder="TO">&nbsp;
            <label>订单审核日期：</label>
            <input type="text" name="start" value="${start}" data-pattern="yyyy/MM/dd" size="12"
                   data-toggle="datepicker"
                   placeholder="FROM">
            <input type="text" name="end" value="${end}" data-pattern="yyyy/MM/dd" size="12" data-toggle="datepicker"
                   placeholder="TO">&nbsp;
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            %{--<button type="button" class="btn-blue"--}%
                    %{--onclick="javascript:bjuiExportExl('#pagerForm', '${request.getContextPath()}/OrderStatus/exportExcel')"--}%
                    %{--data-icon="file-excel-o" title="导出Excel">导出</button>--}%
            <a type="button" class="btn btn-blue" href="${request.getContextPath()}/Base/exportExcel"
               data-toggle="doexport" data-confirm-msg="确定要导出吗？" data-icon="file-excel-o" title="导出Excel">导出</a>
        </div>
    </form>
</div>

<div class="bjui-pageContent tableContent">
    <g:if test="${orderStatus.size() > 0}">
        <table  data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
            <g:each in="${tableHeadList}" status="j" var="headInstance">
            <g:if test="${headInstance != 'RN'}">
                <th width="150"><g:message code="${headInstance}" default="${headInstance}"/></th>
            </g:if>
        </g:each>
        </tr>
        </thead>
        <tbody>
        <g:each in="${orderStatus}" status="i" var="dataInstance">
            <tr>
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance == 'DOC_QTY'}">
                        <td name="ORDERDOC${i}">${dataInstance["${headInstance}"]}</td>
                    </g:if>
                    <g:elseif test="${headInstance == 'PRE_QTY'}">
                        <td name="ORDERPRE${i}"><a
                                href="${request.getContextPath()}/OrderStatus/forFeeding?docId1=<%=dataInstance.DOC_ID%>&lineNum1=<%=dataInstance.LINE_NUM%>"
                                data-toggle="navtab" data-id="dialog-normal"
                                data-options="{id:'orderStatusAnalysis', title:'订单状况分析表待投料'}">${dataInstance["${headInstance}"]}</a>
                        </td>
                    </g:elseif>
                    <g:elseif
                            test="${headInstance == 'WAIT' || headInstance == 'RUN' || headInstance == 'REPAIR' || headInstance == 'FIN' || headInstance == 'HOLD' || headInstance == 'OUTSRC' || headInstance == 'SCRAP' || headInstance == 'SHIP'}">
                        <td name="ORDER${headInstance + i}"><a
                                href="${request.getContextPath()}/OrderStatus/OrderStatusStep?partName1=<%=dataInstance.savepartcode%>&docId1=<%=dataInstance.DOC_ID%>&state1=<%=headInstance%>&lineNum1=<%=dataInstance.LINE_NUM%>"
                                data-toggle="navtab" data-id="dialog-normal"
                                data-options="{id:'orderStatusAnalysis', title:'订单状况分析表二级界面'}">${dataInstance["${headInstance}"]}</a>
                        </td>
                    </g:elseif>
                    <g:elseif test="${headInstance != 'RN'}">
                        <td>${dataInstance["${headInstance}"]}</td>
                    </g:elseif>
                </g:each>
            </tr>
        </g:each>
        <tr>
            <td colspan="11">小计</td>
            <td name="docShow"></td>
            <td name="preShow"></td>
            <td name="waitShow"></td>
            <td name="runShow"></td>
            <td name="holdShow"></td>
            <td name="repairShow"></td>
            <td name="outsrcShow"></td>
            <td name="scrapShow"></td>
            <td name="finShow"></td>
            <td name="shipShow"></td>
        </tr>
        <tr>
            <td colspan="11">合计</td>
            <td>${orderStatusSumQty.DOC[0]}</td>
            <td>${orderStatusSumQty.PRE[0]}</td>
            <td>${orderStatusSumQty.WAIT[0]}</td>
            <td>${orderStatusSumQty.RUN[0]}</td>
            <td>${orderStatusSumQty.HOLD[0]}</td>
            <td>${orderStatusSumQty.REPAIR[0]}</td>
            <td>${orderStatusSumQty.OUTSRC[0]}</td>
            <td>${orderStatusSumQty.SCRAP[0]}</td>
            <td>${orderStatusSumQty.FIN[0]}</td>
            <td>${orderStatusSumQty.SHIP[0]}</td>
        </tr>
    </g:if>
    <g:else>
    <g:render template="../template/emptyPanel" />
    </g:else>
</tbody>
</table>
</div>
<g:render template="../template/51pagination"/>
<script>
    $(function () {

        var orderDoc = 0;
        var orderPre = 0;
        var orderWait = 0;
        var orderRun = 0;
        var orderHold = 0;
        var orderRepair = 0;
        var orderOutsrc = 0;
        var orderScrap = 0;
        var orderFin = 0;
        var orderShip = 0;
        for (var i = 0; i <${orderStatus.size()}; i++) {

            var doc = 'ORDERDOC' + i
            var docAdd = $("td[name='" + doc + "']").text() == '' ? 0 : parseInt($("td[name='" + doc + "']").text());
            orderDoc += docAdd;

            var pre = 'ORDERPRE' + i
            var preAdd = $("td[name='" + pre + "']").text() == '' ? 0 : parseInt($("td[name='" + pre + "']").text());
            orderPre += preAdd;

            var wait = 'ORDERWAIT' + i
            var waitAdd = $("td[name='" + wait + "']").text() == '' ? 0 : parseInt($("td[name='" + wait + "']").text());
            orderWait += waitAdd;

            var run = 'ORDERRUN' + i
            var runAdd = $("td[name='" + run + "']").text() == '' ? 0 : parseInt($("td[name='" + run + "']").text());
            orderRun += runAdd;
//
            var hold = 'ORDERHOLD' + i
            var holdAdd = $("td[name='" + hold + "']").text() == '' ? 0 : parseInt($("td[name='" + hold + "']").text());
            orderHold += holdAdd;

            var repair = 'ORDERREPAIR' + i
            var repairAdd = $("td[name='" + repair + "']").text() == '' ? 0 : parseInt($("td[name='" + repair + "']").text());
            orderRepair += repairAdd;

            var outsrc = 'ORDEROUTSRC' + i
            var outsrcAdd = $("td[name='" + outsrc + "']").text() == '' ? 0 : parseInt($("td[name='" + outsrc + "']").text());
            orderOutsrc += outsrcAdd;

            var scrap = 'ORDERSCRAP' + i
            var scrapAdd = $("td[name='" + scrap + "']").text() == '' ? 0 : parseInt($("td[name='" + scrap + "']").text());
            orderScrap += scrapAdd;

            var fin = 'ORDERFIN' + i
            var finAdd = $("td[name='" + fin + "']").text() == '' ? 0 : parseInt($("td[name='" + fin + "']").text());
            orderFin += finAdd;

            var ship = 'ORDERSHIP' + i
            var shipAdd = $("td[name='" + ship + "']").text() == '' ? 0 : parseInt($("td[name='" + ship + "']").text());
            orderShip += shipAdd;

        }


        $("td[name='docShow']").html(orderDoc);
        $("td[name='preShow']").html(orderPre);
        $("td[name='waitShow']").html(orderWait);
        $("td[name='runShow']").html(orderRun);
        $("td[name='holdShow']").html(orderHold);
        $("td[name='repairShow']").html(orderRepair);
        $("td[name='outsrcShow']").html(orderOutsrc);
        $("td[name='scrapShow']").html(orderScrap);
        $("td[name='finShow']").html(orderFin);
        $("td[name='shipShow']").html(orderShip);

    })
</script>
